package pd_device

import (
	"net"
	"time"

	"github.com/quic-go/quic-go"
)

var _ net.Conn = (*QuicStream)(nil)

type QuicStream struct {
	stream quic.Stream
}

func NewQuicStream(stream quic.Stream) *QuicStream {
	return &QuicStream{stream: stream}
}

func (tis *QuicStream) Read(b []byte) (n int, err error) {
	return tis.stream.Read(b)
}

func (tis *QuicStream) Write(b []byte) (n int, err error) {
	return tis.stream.Write(b)
}

func (tis *QuicStream) Close() error {
	return tis.stream.Close()
}

func (tis *QuicStream) LocalAddr() net.Addr {
	return &net.TCPAddr{
		IP:   net.ParseIP("127.0.0.1"),
		Port: 456,
	}
}

func (tis *QuicStream) RemoteAddr() net.Addr {
	return &net.TCPAddr{
		IP:   net.ParseIP("127.0.0.1"),
		Port: 456,
	}
}

func (tis *QuicStream) SetDeadline(t time.Time) error {
	return tis.stream.SetDeadline(t)
}

func (tis *QuicStream) SetReadDeadline(t time.Time) error {
	return tis.stream.SetReadDeadline(t)
}

func (tis *QuicStream) SetWriteDeadline(t time.Time) error {
	return tis.stream.SetWriteDeadline(t)
}
